package com.crazy.service.sys.impl;

import java.io.Serializable;
import java.util.List;

import javax.inject.Inject;
import javax.transaction.Transactional;

import org.hibernate.criterion.Order;
import org.springframework.data.domain.Page;

import com.crazy.dao.sys.BaseDao;
import com.crazy.service.sys.BaseService;

/**
 * Service基础类——实现类
 * 
 * @author Zhang Weiwei
 * @since 2013-9-20下午2:09:52
 */
@Transactional
public abstract class BaseServiceImpl<Entity> implements BaseService<Entity> {
	@Inject
	protected BaseDao<Entity> dao;

	@Override
	public void delete(Entity entity) {
		dao.delete(entity);
	}

	@Override
	public <PK> void deleteByPK(PK pk) {
		dao.deleteByPK(pk);
	}

	@Override
	public Page<Entity> findAll(Integer pageNum, Integer pageSize,
			Order... orders) {
		return dao.findAll(pageNum, pageSize, orders);
	}

	@Override
	public List<Entity> findAll(Integer maxRow, Order... orders) {
		return dao.findAll(maxRow, orders);
	}

	@Override
	public List<Entity> findAll(Order... orders) {
		return dao.findAll(orders);
	}

	@Override
	public List<Entity> findByExample(Entity entity, Boolean excludeZeroes,
			Boolean excludeNone, Boolean enableLike, Boolean ignoreCase,
			Order... orders) {
		return dao.findByExample(entity, excludeZeroes, excludeNone,
				enableLike, ignoreCase, orders);
	}

	@Override
	public List<Entity> findByExample(Entity entity, Order... orders) {
		return dao.findByExample(entity, orders);
	}

	@Override
	public List<Entity> findByProperty(String propertyName, Object value,
			Order... orders) {
		return dao.findByProperty(propertyName, value, orders);
	}

	@Override
	public Entity findUniqueResult(String propertyName, Object value) {
		return dao.findUniqueResult(propertyName, value);
	}

	@Override
	public List<Entity> findUseInOfArray(String propertyName, Object... values) {
		return dao.findUseInOfArray(propertyName, values);
	}

	@Override
	public Entity get(Serializable pk) {
		return dao.get(pk);
	}

	@Override
	public Entity load(Serializable pk) {
		return dao.load(pk);
	}

	@Override
	public Entity save(Entity entity) {
		return dao.save(entity);
	}

	@Override
	public Entity saveOrUpdate(Entity entity) {
		return dao.saveOrUpdate(entity);
	}

	@Override
	public Entity update(Entity entity) {
		return dao.update(entity);
	}
}
